(#1)
c0rrupt Offline
Administrator
 
Posts: 192
Join Date: Mar 2010
Location: Canada
Show Date [Module] - 11-07-2010, 10:23 AM

by jomasaco on Sun Oct 10, 2010








This mod will show the date in two formats at your choice.
Time elapsed in seconds, minutes,hours,days,months,years
like 2 minutes ago
or in
Today/Yesterday/8-01-10
In both cases the doubled dates are replaced by an arrow.


Code:
    <?php
    if(!defined("WCDDL_GUTS"))
        exit;
    // Config
    $lastupdated = "";
        $modEnabled = false; 
        /*true show time ago in seconds, minutes, hours....
        * false show today, yesterday, date in format d-m-y like 21-06-10
        * in both cases doubled dates are replaced by an up arrow
        */
        if($modEnabled) {
    function time_elapsed_string($download) {
    global $core, $lastupdated;
            $etime = time() - $download;
            if ($etime < 1) {
                return '0 seconds';
            }
            $a = array( 12 * 30 * 24 * 60 * 60  =>  'year',
                30 * 24 * 60 * 60       =>  'month',
                24 * 60 * 60            =>  'day',
                60 * 60                 =>  'hour',
                60                      =>  'minute',
                1                       =>  'second'
            );
            foreach ($a as $secs => $str) {
                $d = $etime / $secs;
                if ($d >= 1) {
                    $r = round($d);
                    $download = $r . ' '.$str . ($r > 1 ? 's' : '') . ' ago';
                    if($lastupdated == $download)
        $download = '<center>[img]./images/arrowup.gif[/img]</center>';
        else
         $lastupdated = $download;
        //$downloadat = $download['dat'];
                    return $download;
                }
            }
        }
    }
    else {
    function time_elapsed_string($download) {
        global $lastupdated;
        if(date("d-m-y") == date("d-m-y",$download)) {
    $download = "Today";
    } elseif(date("d-m-y",strtotime("yesterday")) == date("d-m-y",$download)) {
    $download = "Yesterday";
    } else {
    $download = date("d-m-y",$download);
    }
    if($lastupdated == $download) {
        $download = '<center>[img]./images/arrowup.gif[/img]</center>';
    } else {
         $lastupdated = $download;
        }
        return $download;
    }
    }
    $core->attachDataHook("fetchDownloadsRow","time_elapsed_string");
    ?>

upload this image to images folder this image and rename to arrowup.gif


where you want to show use
Code:
    <?=time_elapsed_string($dl['dat'])?>
To chose the way who the date are presented, on module $modEnabled
$modEnabled = false;
/*true show time ago in seconds, minutes, hours....
* false show today, yesterday, date in format d-m-y like 21-06-10
* in both cases doubled dates are replaced by an up arrow

Thanks to Smoky (http://xtremeddl.net) to provide the test board


Before doing any edits to your DDL Site always make a BACKUP first.

Bookmarks

Tags
date, module, show

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




Powered by vBulletin


Content Relevant URLs by vBSEO